<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="/js/elementui/index.css">
    <style>
        .login_box{
            width: 500px;
            height: 400px;
            margin:100px auto;
        }
    </style>
</head>
<body>
<div id="app" class="login_box">
    <el-card >
        <div slot="header" class="clearfix">
            <span>用户登录</span>
        </div>
        <div>
            <span th:if="${param.error}" style="color: red">账号或密码错误</span>
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="账号">
                    <el-input v-model="form.username"></el-input>
                </el-form-item>
                <el-form-item label="密码">
                    <el-input type="password" v-model="form.password"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="login">登录</el-button>
                    <el-button @click="registerinLogin">注册</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div>
            还未注册，<a href="/registerin/register-company.html">去注册</a>
        </div>
    </el-card>
</div>
<script src="/js/vue/vue.js"></script>
<script src="/js/axios/axios.min.js"></script>
<script src="/js/qs/qs.min.js"></script>
<script src="/js/elementui/index.js"></script>
<script>
    new Vue({
        el:"#app",
        data(){
            return{
                form:{
                    username:"",
                    password:""
                }
            }
        },
        methods:{
            registerinLogin(){
                location.href ="/registerin/register-company.html"
            },
            login(){
                //将JSON转换为表单格式 username=xxx&password=xxx
                axios.post("/login",Qs.stringify(this.form))
                    .then(value => {
                        console.log(value);
                        location.href = value.request.responseURL;
                    });
            }
        }
    })
</script>
</body>
</html>